﻿using System;
using Echo.Context.UltiProNet.Contexts;
using Echo.Core.TestAbstraction.WebUITest.MbUnit;
using Echo.Models.UltiProNet;
using Echo.Models.UltimateSoftware;
using Echo.Models.UltimateSoftware.WebUITest.MbUnit;
using MbUnit.Framework;
using Echo.Core.Common;

////*************************************************************************************************************************************
////Created by: Jannette Hamilton
////Date created: May 6, 2013
////Modified by: 
////Date modified: 
////Reason: 
////ULTI-91892 JIRA Description.
////*************************************************************************************************************************************

namespace Echo.Automation.Compliance.BusinessRules.Locations
{
    [TestFixture]

    [Author("Jannette Hamilton", "Jannette_Hamilton@ultimatesoftware.com")]
    [Category("<Business Rules>")]
    [Header("Config")]
    [Config(".NET")]
    //[Config("IEOnly")]
    //[Config("ChromeOnly")]
    //[Config("FFOnly")]

    public class EditDeleteLocationsUS : MbUnitAutomatedTest
    {
        UltiPro UltiPro;
        UltiProDatabaseContext Database;

        [FixtureSetUp]
        public void FixtureSetUp()
        {
            UltiPro = Launch<UltiPro>();
            Database = Init<UltiProDatabaseContext>();
            Database.Company = ConfigDatabase("UltiPro_CALENDAR");
            Database.Company.AddRollBack("iLocation");
            Database.Company.AddRollBack("Loccomp");
            Database.Company.AddRollBack("Addresses");
            Database.Company.AddRollBack("PhoneNumbers");
            // Login as System Admin JanH and navigate to  System Admin > Business Rules > Locations
            UltiPro.Pages.Login.LoginAs("JanH", "password", Config.LanguageCode);
            UltiPro.Pages.CompanySelector.ChooseMasterCompany("CALEN");
            UltiPro.Pages.CompanySelector.ChooseComponentCompany("C0014");
        }

        [FixtureTearDown]
        public void FixtureTearDown()
        {
            Database.Company.RollBackDatabase();
            UltiPro.Browser.Quit();
        }

        [SetUp]
        public void SetUp()
        {
            UltiPro.Macros.Navigate.ToBusinessRule("Locations");
        }

        [TearDown]
        public void TearDown()
        {
        }

        #region Helper Functions
        public void SelectLocationCode(string sLocCode)
        {
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Find(code => code.CodeFilter, FilterType.Is, sLocCode);
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Row(0).Click(column => column.CodeLink);
        }

        public void SetTaxCodes(string wiCounty, string wiResRate, string wiNonResRate, string occRate, string WCRate, string otherRate)
        {
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInCountyDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInCountyDropdown, wiCounty, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxResidentRateDropdown, wiResRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInTaxNonResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkInTaxNonResidentRateDropdown, wiNonResRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OccupationalDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OccupationalDropdown, occRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkersCompensationDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.WorkersCompensationDropdown, WCRate, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.OtherDropdown);
            UltiPro.Pages.AddChgLocations.Set(combo => combo.OtherDropdown, otherRate, SelectOption.Value);
        }

        public void CheckPhysicalAddressUS()
        {
            UltiPro.Pages.AddChgLocations.Is(page => page.LocationCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(label => label.PhyicalAddressLine1Label, "innerHTML", UltiPro.Localization.Strings.Address_1);
            UltiPro.Pages.AddChgLocations.Is(label => label.PhyicalAddressLine2Label, "innerHTML", UltiPro.Localization.Strings.Address_2);
            UltiPro.Pages.AddChgLocations.NotVisibleOrNotExists(label => label.PhyicalAddressLine3Label);
            UltiPro.Pages.AddChgLocations.NotVisibleOrNotExists(label => label.PhyicalAddressLine4Label);
            UltiPro.Pages.AddChgLocations.NotLike(label => label.PhyicalAddressStateProvinceLabel, "innerHTML", "Province");
            UltiPro.Pages.AddChgLocations.Is(label => label.PhyicalAddressStateProvinceLabel, "innerHTML", UltiPro.Localization.Strings.State);
            UltiPro.Pages.AddChgLocations.Is(label => label.PhyicalAddressZipPostalCodeLabel, "innerHTML", UltiPro.Localization.Strings.Zip_slash_Postal_code);
        }

        public void EditPhysicalAddressUs(string physLine1, string physLine2, string physCity, string physState, string physZip)
        {
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressLine1Texbox, physLine1);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressLine2Texbox, physLine2);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressCityTexbox, physCity);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.PhyicalAddressStateProvinceDropdown, physState, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhyicalAddressZipPostalCodeTexbox, physZip);
        }

        public void EditContactAddressUSorCan(string conCountry, string conLine1, string conLine2, string conCity, string conState, string conZip, string conCounty)
        {
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactCountryDropdown, conCountry, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine1Texbox, conLine1);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine2Texbox, conLine2);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactCityTexbox, conCity);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactStateProvinceDropdown, conState, SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactZipPostalCodeTexbox, conZip);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactCountyTexbox, conCounty);
        }
        #endregion

        #region DELETE TESTS
        #region GIVEN THAT THE LOCATION HAS NO EMPLOYEE OR SALARY DIFFERENTIAL ATTACHED (JMCNES), WHEN DELETE IS HIT, THEN IT SHOULD BE REMOVED FROM THE DB
        [Test(Order = 1)]
        public void DeleteWithSuccess()
        {
            //DB check to verify LOCATION EXISTS
            Database.Company.VerifyRecordCount("SELECT LocCode, LocName, LcpCode, LcpCoid from Location, LocComp where LocCode = LcpCode and LcpCode = 'JMCNES'", 3);

            //SELECT THE LOCATION AND HIT DELETE.  THIS SHOULD BE SUCESSFUL AS THIS LOCATION HAS NO EMPLOYEES OR SALARY DIFFERENTIAL ATTACHED
            SelectLocationCode("JMCNES");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Delete);
            UltiPro.Alert.Accept();
        
            //VERIFY THAT JMCNES NO LONGER DISPLAYS IN THE GUI
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Find(code => code.CodeFilter, FilterType.Is, "JMCNES");
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Row(row => row.Code, "JMCNES", col => col.Description, "Jan Multico NoEE NoSal Df").RowNotExists();

           //DB check to verify LOCATION HAS BEEN DELETED FROM BOTH WEB PAYROL COMPANY & WEB PAYROL TWO COMPANY
           Database.Company.VerifyRecordCount("SELECT LocCode, LocName, LcpCode, LcpCoid from Location, LocComp where LocCode = LcpCode and LcpCode = 'JMCNES'", 0);
          }
        #endregion

        #region GIVEN THAT A LOCATION HAS A SALARY DIFFERENTIAL ATTACHED (JSDNEE), WHEN DELETE IS HIT, THEN IT SHOULD NOT BE REMOVED FROM THE DB AND A HINT SHOULD BE DISPLAYED
        [Test(Order = 2)]
        public void DeleteLocWithSalaryDifferential()
        {
            //SELECT JSDNEE LOCATION AND HIT DELETE.  THIS SHOULD NOT BE SUCESSFUL AS A SALARY DIFFERENTIAL ATTACHED
            SelectLocationCode("JSDNEE");
            UltiPro.Pages.AddChgLocations.ButtonBar.NotEnabled(button => button.Delete);
            UltiPro.Pages.AddChgLocations.Is(hint => hint.DeleteButtonHint, "title", "This location is currently or has previously been assigned to a Salary Differential. The location cannot be deleted while it is being used."); //NOT WORKING
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Back);

            //VERIFY THAT JSDNEE STILL DISPLAYS IN THE GUI
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Find(code => code.CodeFilter, FilterType.Is, "JSDNEE");
            UltiPro.Pages.LocationSummary.LocationSummaryGrid.Row(row => row.Code, "JSDNEE", col => col.Description, "Jannette's Sal Diff No EE").RowExists();

            //DB checks to verify LOCATION HAS NOT BEEN DELETED FROM WEB PAYROL COMPANY
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode from location where loccode in ('JSDNEE')",  "LocationBusinessRules/EditDeleteLocationUS_LocnJSDNEE1.xml");
            Database.Company.Verify("SELECT * from loccomp where lcpcode in ('JSDNEE')", "LocationBusinessRules/EditDeleteLocationUS_LocCompJSDNEE.xml");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS AN EMPLOYEE ATTACHED (NYJAN2), WHEN DELETE IS HIT, THEN IT SHOULD NOT BE REMOVED FROM THE DB AND A HINT SHOULD BE DISPLAYED
        [Test(Order = 3)]
        public void DeleteLocWithEEAttached()
        {
            //SELECT NYJAN2 LOCATION AND HIT DELETE.  THIS SHOULD NOT BE SUCESSFUL AS AN EMPLOYEE IS ATTACHED
            SelectLocationCode("NYJAN2");
            UltiPro.Pages.AddChgLocations.ButtonBar.NotEnabled(button => button.Delete);
            UltiPro.Pages.AddChgLocations.Is(hint => hint.DeleteButtonHint, "title", "This location is currently assigned to one or more employees or has pay records in history. The location cannot be deleted while it is being used.");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS BOTH EMPLOYEE AND SAL DIFF ATTACHED (JEENSD), WHEN DELETE IS HIT, THEN IT SHOULD NOT BE REMOVED FROM THE DB AND A HINT SHOULD BE DISPLAYED
        [Test(Order = 4)]
        public void DeleteLocWithEEAndSalaryDifferential()
        {
            SelectLocationCode("JEENSD");
            UltiPro.Pages.AddChgLocations.ButtonBar.NotEnabled(button => button.Delete);
            UltiPro.Pages.AddChgLocations.Like(hint => hint.DeleteButtonHint, "title", "This location is currently assigned to one or more employees and is currently or previously been assigned to a Salary Differential. The location cannot be deleted while it is being used.");
        }
        #endregion
        #endregion

        #region EDIT TESTS
        #region GIVEN THAT A LOCATION HAS AT LEAST ONE EMPLOYEE ATTACHED (KYBFJH), WHEN THE EDIT BUTTON IS HIT, THEN THE LOCAL TAXES SECTION IS DISABLED
        [Test(Order = 5)]
        public void EditLocWithEEAttached()
        {
            var inactDate2 = DateTime.Today;

            // VERIFY THAT THE LOCAL TAX SECTION CODE CANNOT BE EDITED.  
            // USING PHYSICAL AND CONTACT ADDRESS = USA: VERIFY ADDRESSES 3, 4, & PROVINCE ARE HIDDEN. LABELS STATE & ZIP/POSTAL CODE ARE DISPLAYED
            SelectLocationCode("KYBFJH");
            UltiPro.Pages.AddChgLocations.Is(page => page.LocationCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Edit);
            CheckPhysicalAddressUS();

            // CHANGES BEGIN HERE
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.EnglishTextBox, "JH CHANGE TRD NAME");
            EditPhysicalAddressUs("25 Physical Line1", "Physical Apt2", "PhysicalCityKY", "KY", "12345");
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.WorkInStateDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.WorkInCountyDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.WorkInTaxResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.WorkInTaxNonResidentRateDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.OccupationalDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.WorkersCompensationDropdown);
            UltiPro.Pages.AddChgLocations.NotEnabled(combo => combo.OtherDropdown);

            // CONTACT INFO: ADDRESS 3 & 4 & STATE/PROVINCE MUST APPEAR UNTIL USA IS SELECTED
            UltiPro.Pages.AddChgLocations.Click(checkbox => checkbox.InactiveCheckbox);
            UltiPro.Pages.AddChgLocations.Visible(label => label.ContactAddressLine3Label);
            UltiPro.Pages.AddChgLocations.Visible(label => label.ContactAddressLine4Label);
            UltiPro.Pages.AddChgLocations.Is(label => label.ContactStateProvinceLabel, "innerHTML", UltiPro.Localization.Strings.State_slash_Province);
            EditContactAddressUSorCan("USA", "1001 Contact Line1", "Contact Building1", "Contact City", "FL", "987654321", "ContactCounty");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhoneNumberTextbox, "954 6891234");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhoneNumberTextbox, "(954) 689-1234");

            //WHEN TAX CODES ARE NOT SETUP FOR A COMPANY THEN THE CHANGES CANNOT BE SAVED AND THE CORRECT ERROR MESSGES ARE DISPLAYED
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, "Chequemates US 1", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
         
            //SHOULD GET ERROR RE TAX CODES THAT ARE NOT SETUP ON Chequemates US 1
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"KYSIT\" not setup for \"Chequemates US 1\".");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"KY164\" not setup for \"Chequemates US 1\".");
            UltiPro.Pages.AddChgLocations.ErrorMessages.Has("Tax code \"KY165\" not setup for \"Chequemates US 1\".");

            //WHEN THE COMPANY (Chequemates US 1) IS REMOVED FROM THE SELECTED LIST THEN THE CHANGES CAN BE SAVED
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Destination, "Chequemates US 1", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowLeft);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);

            //WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode, LocContactAddressCity, LocContactAddressCountry, LocContactAddressCounty,LocContactAddressLine1, LocContactAddressLine2, LocContactAddressLine3, LocContactAddressLine4, LocContactAddressState, LocContactAddressZipcode, LocPhoneFaxNumber,LocPhoneMainExt, LocPhoneMainNumber, LocPhoneMainNumberCountryCode from location where loccode in ('KYBFJH') ORDER BY loccode", "LocationBusinessRules/EditDeleteLocationUS_LocKYBFJH.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpIsInactive from loccomp where lcpcode in ('KYBFJH') and LcpCoID = 'C0014'", "LocationBusinessRules/EditDeleteLocationUS_LocCompWebPyrlKYBFJH.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpIsInactive from loccomp where lcpcode in ('KYBFJH') and LcpCoID = 'XB3CV'", "LocationBusinessRules/EditDeleteLocationUS_LocCompWebPyrl2KYBFJH.xml");

            //WHEN THE CHANGES ARE SAVED, THEN THE GUI IS UPDATED WITH THE CHANGES
            UltiPro.Pages.AddChgLocations.Is(page => page.LocationCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.CodeValue, "innerHTML", "KYBFJH");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueEn, "innerHTML", "JH CHANGE TRD NAME");
            UltiPro.Pages.AddChgLocations.Selected(checkbox => checkbox.InactiveCheckbox);
            UltiPro.Pages.AddChgLocations.Is(page => page.InactiveDateValue, "innerHTML", inactDate2.ToString("MM/dd/yyyy"));

            // PHYSICAL ADDRESS
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine1Value, "innerHTML", "25 Physical Line1");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine2Value, "innerHTML", "Physical Apt2");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCityValue, "innerHTML", "PhysicalCityKY");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressStateProvinceValue, "innerHTML", "Kentucky");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressZipPostalCodeValue, "innerHTML", "12345");

            // CONTACT INFORMATION 
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine1Value, "innerHTML", "1001 Contact Line1");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine2Value, "innerHTML", "Contact Building1");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCityValue, "innerHTML", "Contact City");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactStateProvinceValue, "innerHTML", "Florida");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactZipPostalCodeValue, "innerHTML", "98765-4321");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountyValue, "innerHTML", "ContactCounty");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhoneNumberValue, "innerHTML", "(954) 689-1234");

            // TAX INFORMATION
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInStateValue, "innerHTML", "KYSIT - KY State Income Tax");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInCountyValue, "innerHTML", "BOONE-FLORENCE - BOONE-FLORENCE");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxResidentRateValue, "innerHTML", "KY162 - Florence City - 2.00%");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxNonResidentRateValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.Is(page => page.OccupationalValue, "innerHTML", "KY164 - Boone Cnty Occupational - 0.80%");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkersCompensationValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.Is(page => page.OtherValue, "innerHTML", "KY165 - Boone Mental License Fee - 0.15%");
            UltiPro.Pages.AddChgLocations.Is(page => page.CompaniesUsingThisTaxLocationList(1), "innerHTML", "Web Payroll Company");
            UltiPro.Pages.AddChgLocations.Is(page => page.CompaniesUsingThisTaxLocationList(2), "innerHTML", "Web Payroll Two Company");
            UltiPro.Pages.AddChgLocations.NotLike(page => page.OtherValue, "innerHTML", "<unavailable>");
        }
        #endregion

        #region GIVEN THAT A LOCATION HAS NO EMPLOYEE ATTACHED (JANFL), WHEN THE EDIT BUTTON IS HIT, THEN ALL FIELDS EXCEPT (COUNTRY & CODE) ARE EDITABLE
        [Test(Order = 6)]
        public void EditLocWithNoEEAttached()
        {
            // USING PHYSICAL ADDRESS = USA, AND CONTACT ADDRESS = GLOBAL (BRAZIL)
            SelectLocationCode("JANFL");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Edit);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.TradeNameTextbox.EnglishTextBox, "JANNETTE NEW TN");
            EditPhysicalAddressUs("101 WHITE OAK STREET", "SUTIE 12B", "WHITE PLAINS", "NY", "12345");

            // CONTACT INFO: VERIFY LABELS ADDRESS 1 - 4; STATE/PROVINCE; & POSTAL CODE ARE DISPLAYED
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactCountryDropdown, "BRA", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine1Texbox, "23 BRAZIL LINE1");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine2Texbox, "BRAZIL LINE 2");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine3Texbox, "BRAZIL LINE 3");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactAddressLine4Texbox, "BRAZIL LINE 4");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactCityTexbox, "BRAZILIA");
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.ContactStateProvinceDropdown, "DF", SelectOption.Value);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactZipPostalCodeTexbox, "01000-000");
            UltiPro.Pages.AddChgLocations.Is(label => label.ContactStateProvinceLabel, "innerHTML", UltiPro.Localization.Strings.State_slash_Province);
            UltiPro.Pages.AddChgLocations.Is(label => label.ContactZipPostalCodeLabel, "innerHTML", UltiPro.Localization.Strings.Postal_code);
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ContactNameTexbox, "DIANNA HAMILTON");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.PhoneNumberTextbox, "(914) 535-1980");
            UltiPro.Pages.AddChgLocations.Set(textbox => textbox.ExtensionTextbox, "5351981111");

            // CHANGE COUNTY, TAX CODES, REMOVE WEB PAYROLL COMPANY, ADD WEB PAYROLL TWO COMPANY
            UltiPro.Pages.AddChgLocations.Enabled(combo => combo.WorkInStateDropdown);
            UltiPro.Pages.AddChgLocations.Set(dropdown => dropdown.WorkInStateDropdown, "IN State Income Tax", SelectOption.Text);
            SetTaxCodes("HAMILTON", "IN017", "IN018", "", "", "");
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Destination, "Web Payroll Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowLeft);
            UltiPro.Pages.AddChgLocations.Set(company => company.CompaniesOptionMover.Source, "Web Payroll Two Company", SelectOption.Text);
            UltiPro.Pages.AddChgLocations.Click(button => button.CompaniesOptionMover.ArrowRight);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);

            //WHEN THE CHANGES ARE SAVED, THEN THE GUI IS UPDATED WITH THE CHANGES: PHYSICAL ADDRESS
            UltiPro.Pages.AddChgLocations.Is(page => page.LocationCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.CodeValue, "innerHTML", "JANFL");
            UltiPro.Pages.AddChgLocations.Is(page => page.TradeNameValueEn, "innerHTML", "JANNETTE NEW TN");
            UltiPro.Pages.AddChgLocations.Is(combo => combo.PhyicalAddressCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine1Value, "innerHTML", "101 WHITE OAK STREET");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine2Value, "innerHTML", "SUTIE 12B");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCityValue, "innerHTML", "WHITE PLAINS");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressStateProvinceValue, "innerHTML", "New York"); 
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressZipPostalCodeValue, "innerHTML", "12345"); 

            // CONTACT INFORMATION 
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountryValue, "innerHTML", "Brazil");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine1Value, "innerHTML", "23 BRAZIL LINE1");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine2Value, "innerHTML", "BRAZIL LINE 2");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine3Value, "innerHTML", "BRAZIL LINE 3");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine4Value, "innerHTML", "BRAZIL LINE 4");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCityValue, "innerHTML", "BRAZILIA");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactStateProvinceValue, "innerHTML", "Federal District");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactZipPostalCodeValue, "innerHTML", "01000000");
            UltiPro.Pages.AddChgLocations.Is(textbox => textbox.ContactNameValue, "innerHTML", "DIANNA HAMILTON");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhoneNumberValue, "innerHTML", "9145351980");
            UltiPro.Pages.AddChgLocations.Is(textbox => textbox.ExtensionValue, "innerHTML", "5351981111");

            //TAX INFORMATION: VERIFY THAT THE LOCAL TAXES SECTION CAN BE EDITED.
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInStateValue, "innerHTML", "INSIT - IN State Income Tax");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInCountyValue, "innerHTML", "HAMILTON - HAMILTON");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxResidentRateValue, "innerHTML", "IN017 - Hamilton - 1.00%");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxNonResidentRateValue, "innerHTML", "IN018 - Hamilton - 0.25%");
            UltiPro.Pages.AddChgLocations.Is(page => page.OccupationalValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.NotLike(page => page.OccupationalValue, "innerHTML", "<unavailable>");
            UltiPro.Pages.AddChgLocations.Is(page => page.CompaniesUsingThisTaxLocationList(1), "innerHTML", "Web Payroll Two Company");

            //WHEN THE CHANGES ARE SAVED, THEN THE DBs ARE UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANFL') and LcpCoID = 'C0014'", "LocationBusinessRules/EditDeleteLocationUS_LocCompWebPyrlJANFL.xml");
            Database.Company.Verify("SELECT LcpCode, LcpCoID, LcpInactiveDate,LcpIsInactive from loccomp where lcpcode in ('JANFL') and LcpCoID = 'XB3CV'", "LocationBusinessRules/EditDeleteLocationUS_LocCompWebPyrl2JANFL.xml");
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressLine3, LocAddressLine4, LocAddressState,LocAddressZipcode, LocContact, LocPhoneMainExt, LocPhoneMainNumber from location where loccode in ('JANFL')", "LocationBusinessRules/EditDeleteLocationUS_LocJANFL.xml");
        }
        #endregion
      
        #region GIVEN THAT A LOCATION (JANHPA) IS NOT SETUP WITH THE RECOMMEMDED TAX CODES AND HAS NO EMPLOYEE ATTACHED TO IT...
        // VERIFY THAT THE RECOMMENDED TAX CODES CAN BE SELECTED IN THE Links and Rates WINDOW
        // USING PHYSICAL ADDRESS = USA & CONTACT ADDRESS = CAN: VERIFY ADDRESSES 3, 4, & STATE ARE HIDDEN. LABELS PROVINCE & POSTAL CODE ARE DISPLAYED
            
        [Test(Order = 7)]
        public void SelectRecommendedTaxCodes()
        {
            //DB CHECKS TO VERIFY THAT NO EMPLOYEE IS ASSIGNED TO LOCATION
            Database.Company.Verify("select * FROM  empcomp where eeclocation = 'JANHPA'", "LocationBusinessRules/EditDeleteLocationUS_EmpCompJANHPA");
            Database.Company.Verify("select * from empmloc where emlcode = 'JANHPA'", "LocationBusinessRules/EditDeleteLocationUS_EmpMLocJANHPA");

            // USING PHYSICAL AND CONTACT ADDRESS = USA: VERIFY ADDRESSES 3, 4, & PROVINCE ARE HIDDEN.  LABELS STATE & ZIP/POSTAL CODE IS DISPLAYED
            SelectLocationCode("JANHPA");
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Edit);
            CheckPhysicalAddressUS();

            // ADD PHYSICAL ADDRESS & CANADIAN CONTACT INFORMATION
            EditPhysicalAddressUs("8000 OAKLAND PARK BLVD", "STE 3001", "SUNRISE", "FL", "333194629");
            EditContactAddressUSorCan("CAN", "2001 Contact Line1 CAN", "10 Contact Building CAN", "Contact City Du CAN", "MB", "J7H 2G2", "");
            UltiPro.Pages.AddChgLocations.NotVisibleOrNotExists(label => label.ContactAddressLine3Label);
            UltiPro.Pages.AddChgLocations.NotVisibleOrNotExists(label => label.ContactAddressLine4Label);
            UltiPro.Pages.AddChgLocations.Is(label => label.ContactStateProvinceLabel, "innerHTML", UltiPro.Localization.Strings.Province);
            UltiPro.Pages.AddChgLocations.Is(label => label.ContactZipPostalCodeLabel, "innerHTML", UltiPro.Localization.Strings.Postal_code);
            
            #region CHECK TAXCODES BEFORE CHANGE ***WORK-IN COUNTY BOX***
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);
            System.Threading.Thread.Sleep(4000); // THIS WINDOW DOES NOT PASTE COMPLETELY (IN FF & CHROME) SOMETIMES SO SLOW DOWN THE SCRIPT
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyCodeValue, "innerHTML", "CAMBRIA");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyDescriptionValue, "innerHTML", "CAMBRIA");
            #endregion

            #region ***WORK-IN TAX RESIDENT RATE BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentCodeValue, "innerHTML", "PA103084");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentDescValue, "innerHTML", "ADAMS");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentRateValue, "innerHTML", "1.00%"); // SOMETIMES FAILS ON FF.  SEE'S ""
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentNonResRateValue, "innerHTML", "1.00%"); // SOMETIMES FAILS ON FF.  SEE'S ""
            #endregion

            #region ***OCCUPATIONAL TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OccupationalTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentCode, "innerHTML", "PA100069");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OccupationalTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedCode, "innerHTML", "PA113877");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedDescription, "innerHTML", "ADAMS TWP");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedRate, "innerHTML", "$52.00");
            #endregion

            #region ***OTHER TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OtherTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentCode, "innerHTML", "PA111571");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OtherTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedCode, "innerHTML", "PA113878");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedDescription, "innerHTML", "FOREST HILLS SD");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedRate, "innerHTML", "$0.00");
            #endregion

            #region WHEN THE RECOMMENDED CODES ARE SELECTED IN THE LINKS AND RATES WINDOW AND THE CHANGES ARE SAVED...
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(radiobtn => radiobtn.OccupationalTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(radiobtn => radiobtn.OtherTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.OkButton);
            UltiPro.Pages.AddChgLocations.ButtonBar.Click(button => button.Save);
            #endregion

            #region THEN THE LOCAL TAXES GUI  IS UPDATED WITH THE CHANGES
            UltiPro.Pages.AddChgLocations.Click(header => header.TaxInformationHeader);
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInStateValue, "innerHTML", "PASIT - PA State Income Tax");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInCountyValue, "innerHTML", "CAMBRIA - CAMBRIA");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxResidentRateValue, "innerHTML", "PA103084 - ADAMS");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkInTaxNonResidentRateValue, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.Is(page => page.OccupationalValue, "innerHTML", "PA113877 - ADAMS TWP - $52.00");
            UltiPro.Pages.AddChgLocations.Is(page => page.WorkersCompensationValue, "innerHTML", "PA112317 - JOHNSTOWN-DISTRESS TAX - 0.10%");
            UltiPro.Pages.AddChgLocations.Is(page => page.OtherValue, "innerHTML", "PA113878 - FOREST HILLS SD - $0.00");
            #endregion

            #region THEN THE PHYSICAL ADDRESS AND CONTACT INFORMATION IS UPDATED
            // PHYSICAL ADDRESS
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCountryValue, "innerHTML", "United States");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine1Value, "innerHTML", "8000 OAKLAND PARK BLVD");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressLine2Value, "innerHTML", "STE 3001");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressCityValue, "innerHTML", "SUNRISE");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressStateProvinceValue, "innerHTML", "Florida");
            UltiPro.Pages.AddChgLocations.Is(page => page.PhyicalAddressZipPostalCodeValue, "innerHTML", "33319-4629");

            //CONTACT INFO
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCountryValue, "innerHTML", "Canada");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine1Value, "innerHTML", "2001 Contact Line1 CAN");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactAddressLine2Value, "innerHTML", "10 Contact Building CAN");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactCityValue, "innerHTML", "Contact City Du CAN");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactStateProvinceValue, "innerHTML", "Manitoba");
            UltiPro.Pages.AddChgLocations.Is(page => page.ContactZipPostalCodeValue, "innerHTML", "J7H 2G2");
            #endregion

            #region CHECK THE THE LINKS AND RATES WINDOW TO VERIFY THAT THE RECOMMENDED & CURRENT TAXCODES ARE UPDATED (BOTH SHOULD BE THE SAME)
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentCode, "innerHTML", "PA113877");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentDescription, "innerHTML", "ADAMS TWP");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentRate, "innerHTML", "$52.00");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedCode, "innerHTML", "PA113877");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedDescription, "innerHTML", "ADAMS TWP");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedRate, "innerHTML", "$52.00");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentCode, "innerHTML", "PA113878");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentDescription, "innerHTML", "FOREST HILLS SD");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentRate, "innerHTML", "$0.00");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedCode, "innerHTML", "PA113878");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedDescription, "innerHTML", "FOREST HILLS SD");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedRate, "innerHTML", "$0.00");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.OkButton);
            #endregion

            // WHEN THE CHANGES ARE SAVED, THEN THE LOCATION TABLE IS UPDATED WITH THE CHANGES
            Database.Company.Verify("SELECT loccode, LocName, LocDesc, loccountrycode, LocSITWorkInStateCode,LocLITWorkInCounty, LocLITResWorkInCode,LocLITNonResWorkInCode, LocLITOCCCode, LocLITWCCCode,LocLITOtherCode, LocAddressCountry, LocIsInactive, LocAddressCity, LocAddressCounty, LocAddressLine1, LocAddressLine2, LocAddressState, LocAddressZipcode from location where loccode in ('JANHPA')", "LocationBusinessRules/EditDeleteLocationUS_JANHPA.xml");
        }
        #endregion
        #endregion

        #region CHECK VIEW LINKS AND RATES WINDOW.
        // THIS TEST FAILS ON IE IF DONE IN ONE TEST SO BREAK IT UP INTO THREE PARTS WITH LESS REGIONS
        
        #region TOP THIRD OF VIEW LINKS AND RATES WINDOW
        [Test(Order = 8)]
        public void CheckLinksAndRatesWindowTopThird()
        {
            #region GIVEN THAT I SELECT LOCATION "JANMO", WHEN I CLICK THE View Links and Rates BUTTON, THEN THE LINKS AND RATES WINDOW IS DISPLAYED WITH THE FOLLOWING SECTIONS & DATA: ***HEADER***
            SelectLocationCode("JANMO");
            UltiPro.Pages.AddChgLocations.Click(header => header.TaxInformationHeader);
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Enabled(header => header.LinksAndRatesHeader);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(header => header.LinksAndRatesHeader, "innerHTML", UltiPro.Localization.Strings.Links_and_rates);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(header => header.LocalHeader, "innerHTML", UltiPro.Localization.Strings.Local);
            #endregion

            #region ***WORK-IN COUNTY BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Enabled(legend => legend.WorkInCountyLegend);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(legend => legend.WorkInCountyLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_county);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInCountyCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyCodeValue, "innerHTML", "ST LOUIS");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInCountyDescriptionLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInCountyDescriptionValue, "innerHTML", "ST LOUIS");
            #endregion

            #region ***WORK-IN TAX RESIDENT RATE BOX & WORK-IN TAX NON-RESIDENT RATE BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkInResidentRateLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_Tax_hyphen_Resident_Rate.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentCodeValue, "innerHTML", "MOSTLEE");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentDescValue, "innerHTML", "St Louis");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentRateLabel, "innerHTML", UltiPro.Localization.Strings.Resident_Rate.ToSentenceCase());

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInResidentNonResRateLabel, "innerHTML", UltiPro.Localization.Strings.Non_hyphen_Resident_rate.ToSentenceCase());
            
            // WORK-IN TAX NON-RESIDENT RATE BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkInNonResidentRateLegend, "innerHTML", UltiPro.Localization.Strings.Work_hyphen_in_Tax_hyphen_Non_hyphen_resident_Rate.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentCodeValue, "innerHTML", "MOSTLEP");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentDescValue, "innerHTML", "St Louis ER Paid");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkInNonResidentRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInNonResidentRateValue, "innerHTML", "1.00%");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.CancelButton);
            #endregion
         }
         #endregion

        #region MIDDLE THIRD OF VIEW LINKS AND RATES WINDOW
        [Test(Order = 9)]
         public void CheckLinksAndRatesWindowSecondThird()
         {
            #region GIVEN THAT I SELECT LOCATION "JANMO" WHEN I CLICK THE View Links and Rates BUTTON THEN THESE SECTIONS EXIST ***WORKERS' COMPENSATION TAX BOX***
            SelectLocationCode("JANMO");
            UltiPro.Pages.AddChgLocations.Click(header => header.TaxInformationHeader);
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.WorkersCompTaxLegend, "innerHTML", UltiPro.Localization.Strings.Workers_apostrophe_compensation_tax);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.WorkersCompTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentCode, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentDescription, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxCurrentRate, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.WorkersCompTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.WorkersCompTaxRecommendedLabel, "innerHTML", UltiPro.Localization.Strings.Recommended);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedCode, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedDescription, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkersCompTaxRecommendedRate, "innerHTML", "");
            #endregion

            #region ***OTHER TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.OtherTaxLegend, "innerHTML", UltiPro.Localization.Strings.Other_Tax.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OtherTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentCode, "innerHTML", "MOSTLER");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentDescription, "innerHTML", "St Louis Payroll Exp");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxCurrentRate, "innerHTML", "0.50%");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OtherTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OtherTaxRecommendedLabel, "innerHTML", UltiPro.Localization.Strings.Recommended);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedCode, "innerHTML", "MOSTLER");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedDescription, "innerHTML", "St Louis Payroll Exp");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OtherTaxRecommendedRate, "innerHTML", "0.50%");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.CancelButton);
            #endregion
        }
        #endregion

        #region LAST THIRD OF VIEW LINKS AND RATES WINDOW
        //THIS TEST HAS AREAS THAT FAIL ON ALL THE BROWSERS AS NOTED BELOW
        [Test(Order = 10)]
        public void CheckLinksAndRatesWindowEditLastThird()
        {
            #region GIVEN THAT I SELECT LOCATION "JANMO" WHEN I CLICK THE View Links and Rates BUTTON
            SelectLocationCode("JANMO");
            UltiPro.Pages.AddChgLocations.Click(header => header.TaxInformationHeader);
            //UltiPro.Pages.AddChgLocations.PressKeyboardKey(header => header.TaxInformationHeader, KeyboardKey.PageDown);
            UltiPro.Pages.AddChgLocations.Click(btn => btn.LinksAndRatesButton);
            #endregion

            #region ***OCCUPATIONAL TAX BOX***
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(lgnd => lgnd.OccupationalTaxLegend, "innerHTML", UltiPro.Localization.Strings.Occupational_Tax.ToSentenceCase());
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxCodeLabel, "innerHTML", UltiPro.Localization.Strings.Code);

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Selected(radiobtn => radiobtn.OccupationalTaxCurrentRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxCurrentLabel, "innerHTML", UltiPro.Localization.Strings.Current);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentCode, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxDescLabel, "innerHTML", UltiPro.Localization.Strings.Description);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentDescription, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxRateLabel, "innerHTML", UltiPro.Localization.Strings.Rate);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxCurrentRate, "innerHTML", "");

            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.NotSelected(radiobtn => radiobtn.OccupationalTaxRecommendedRadioButton);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(label => label.OccupationalTaxRecommendedLabel, "innerHTML", UltiPro.Localization.Strings.Recommended);
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentRateValue, "innerHTML", "1.00%"); // SOMETIMES FAILS ON FF.  SEE'S ""
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.WorkInResidentNonResRateValue, "innerHTML", "0.00%"); //SOMETIMES FAILS ON FF.  SEE'S ""
            //THESE 3 LINES DO NOT WORK ON IE ONLY.  IE SEES " ".  
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedCode, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedDescription, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Is(page => page.OccupationalTaxRecommendedRate, "innerHTML", "");
            UltiPro.Pages.AddChgLocations.LocationViewLinksAndRatesDialog.Click(button => button.CancelButton);
            #endregion
        }
        #endregion
       }
       #endregion
}